package com.bigzero.workflow.modules.process.controller;

import com.bigzero.workflow.common.model.TableDataInfo;
import com.bigzero.workflow.common.model.TokenInfo;
import com.bigzero.workflow.common.utils.TokenUtil;
import com.bigzero.workflow.modules.process.query.FinishedQuery;
import com.bigzero.workflow.modules.process.service.HistoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 已办任务前端控制器
 * @author fanxinxiong
 * @since 2025-02-13
 */
@RestController
@RequestMapping("/process/finished")
@Tag(name = "与我有关-已办任务")
public class FinishedController {

    @Autowired
    private HistoryService historyService;

    /**
     * 查看我代办的流程
     *
     * @param finishedQuery 参数
     */
    @Tag(name = "与我有关-已办任务")
    @Operation(summary = "分页列表", description = "分页列表")
    @GetMapping("list")
    public TableDataInfo list(FinishedQuery finishedQuery){
        TokenInfo tokenInfo = TokenUtil.getTokenInfo();
        finishedQuery.setUserId(tokenInfo.getId());
        return historyService.queryPage(finishedQuery);
    }
}
